/* eslint-disable @typescript-eslint/no-redeclare */
// import CustomerTree from "@/components/CustomerTree";
import { EllipsisOutlined } from "@ant-design/icons";
import { Dropdown, Tree, Typography } from "antd";
import React, { useState } from "react";
export type TreeProps = {
	onSelect: (values: any) => Promise<void>;
	treeData: any;
};
const OrgTree: React.FC<TreeProps> = props => {
	// const [treeData, setTreeData] = useState<any>([]);
	const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
	const [autoExpandParent, setAutoExpandParent] = useState<boolean>(true);
	const { onSelect = () => {}, treeData } = props;

	const onSelected = (keys: React.Key[], info: any) => {
		info.node.id = info.node.key;
		onSelect(info.node);
	};

	const onExpand = (expandedKeysValue: React.Key[]) => {
		setExpandedKeys(expandedKeysValue);
		setAutoExpandParent(false);
	};
	const [expandAll, setExpandAll] = useState<boolean>(false);
	const items = [
		{
			key: "1",
			label: <Typography>添加下级节点</Typography>
		},
		{
			key: "2",
			label: <Typography>编 辑</Typography>
		},
		{
			key: "3",
			label: <Typography>删 除</Typography>
		}
	];

	return (
		<Tree
			blockNode
			// isOrgTree={true}
			treeData={treeData}
			// showSearch={false}
			fieldNames={{
				title: "deptName",
				key: "id",
				children: "children"
			}}
			defaultExpandAll={expandAll}
			onExpand={onExpand}
			expandedKeys={expandedKeys}
			// autoExpandParent={autoExpandParent}
			// eslint-disable-next-line @typescript-eslint/no-unused-vars
			// renderOperationMenuItems={(node: any) => (
			// 	<Dropdown menu={{ items }}>
			// 		<EllipsisOutlined />
			// 	</Dropdown>
			// )}
			onSelect={(keys, info) => {
				onSelected(keys, info);
			}}
		/>
	);
};

export default OrgTree;
